package com.isoftstone.storage.resource;

import com.isoftstone.storage.StorageConstants;

/**
 * 资源
 * 
 * 
 */
public class Resource {
	private String name;
	private long contentLength = StorageConstants.UNKNOWN_LENGTH;

	public Resource() {
	}

	public Resource(String name) {
		this.name = name;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public long getContentLength() {
		return contentLength;
	}

	public void setContentLength(long contentLength) {
		this.contentLength = contentLength;
	}

	public String toString() {
		return name;
	}

	public String inspect() {
		return name + "[len = " + contentLength + "]";
	}

	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result
				+ (int) (contentLength ^ (contentLength >>> 32));
		result = prime * result + ((name == null) ? 0 : name.hashCode());
		return result;
	}

	public boolean equals(Object obj) {
		if (this == obj) {
			return true;
		}
		if (obj == null) {
			return false;
		}
		if (getClass() != obj.getClass()) {
			return false;
		}
		final Resource other = (Resource) obj;
		if (contentLength != other.contentLength) {
			return false;
		}
		if (name == null) {
			if (other.name != null) {
				return false;
			}
		} else if (!name.equals(other.name)) {
			return false;
		}
		return true;
	}
}
